import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import './style.css'
import vReveal from './directives/reveal'
import router from './router'

// 全局错误处理
window.addEventListener('error', (event) => {
  if (event.message && event.message.includes('ResizeObserver')) {
    event.preventDefault()
    console.warn('ResizeObserver错误已被忽略:', event.message)
  }
})

// 处理未捕获的Promise错误
window.addEventListener('unhandledrejection', (event) => {
  if (event.reason && event.reason.message && event.reason.message.includes('ResizeObserver')) {
    event.preventDefault()
    console.warn('ResizeObserver Promise错误已被忽略:', event.reason.message)
  }
})

const app = createApp(App)
const pinia = createPinia()

app.use(pinia)
app.use(ElementPlus)
app.use(router)
app.directive('reveal', vReveal)

app.mount('#app')